<template>
  <div class="affix-demo">
    <div v-height="150" class="bg-gray3-color relative">
      <div>
        <d-affix :offset-top="70" @change="onchange1">
          <button class="d-btn" :class="{'d-btn-green': status.fixed1}">
            固定在距离顶部偏移量70px的位置
          </button>
        </d-affix>
      </div>
      <div v-height="10"></div>
      <div>
        <d-affix :offset-top="120" @change="onchange2">
          <button class="d-btn" :class="{'d-btn-yellow': status.fixed2}">
            固定在距离顶部偏移量120px的位置
          </button>
        </d-affix>
      </div>
      <div v-height="10"></div>
      <div>
        <d-affix :offset-top="170" @change="onchange3">
          <button class="d-btn" :class="{'d-btn-blue': status.fixed3}">
            固定在距离顶部偏移量170px的位置
          </button>
        </d-affix>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'demo1',
  data () {
    return {
      status: {
        fixed1: false,
        fixed2: false,
        fixed3: false
      }
    }
  },
  methods: {
    onchange1 (fixed) {
      this.status.fixed1 = fixed
    },
    onchange2 (fixed) {
      this.status.fixed2 = fixed
    },
    onchange3 (fixed) {
      this.status.fixed3 = fixed
    }
  }
}
</script>

<style lang="stylus" scoped>
// .affix-demo
</style>
